﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NZBMatrixAdvancedFeedReader
{
    public partial class frmSettings : Form
    {
        public frmSettings()
        {
            InitializeComponent();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            int tempNum;

            if (int.TryParse(txtNZBMatrixMaxPostAge.Text, out tempNum))
                Classes.SystemSettings.MaxPostAge = tempNum;
            Classes.SystemSettings.NZBMatrix.UserName = txtNZBMatrixUsername.Text;
            Classes.SystemSettings.NZBMatrix.APIKey = txtNZBMatrixAPIKey.Text;

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void frmSettings_Load(object sender, EventArgs e)
        {
            //Load Data
            if (Classes.SystemSettings.MaxPostAge > 0)
                txtNZBMatrixMaxPostAge.Text = Classes.SystemSettings.MaxPostAge.ToString();
            txtNZBMatrixUsername.Text = Classes.SystemSettings.NZBMatrix.UserName;
            txtNZBMatrixAPIKey.Text = Classes.SystemSettings.NZBMatrix.APIKey;
        }
    }
}
